import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standardization_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/standardization/common.dart';
import 'package:flutter/material.dart';

/// 持续改进-台账
class ImproveBook extends StatelessWidget {
  const ImproveBook({required this.type, super.key});

  // 0:改进台账 1:检查台账
  final int type;

  Future<List<StandardizationEntity>> getPages(
    int idx,
    int size, {
    String? search,
  }) async {
    final resp = await HttpUtil().generateGetRequest<List<StandardizationEntity>>(
      '${Interface.mainBaseUrl}/standard//ReportLedger/getReportLedgerPage',
      queryParameters: {
        'pageNum': idx,
        'pageSize': size,
        'type': type,
        'name': search,
      },
    ).execute();
    return resp.data ?? [];
  }

  @override
  Widget build(BuildContext context) {
    return _buildBody();
  }

  Widget _buildBody() {
    return CustomEasyRefreshList<StandardizationEntity>(
      isShowSearch: true,
      dataLoad: getPages,
      itemBuilder: StandardizationCommon.card,
    );
  }
}
